16 #ifdef __MSP430_HAS_USCI_Bx__
21 bool USCI_B_SPI_initMaster(uint16_t baseAddress, USCI_B_SPI_initMasterParam *
param)
24 HWREG8(baseAddress + OFS_UCBxCTL1) |= UCSWRST;
27 HWREG8(baseAddress + OFS_UCBxCTL0) &= ~(UCCKPH + UCCKPL + UC7BIT + UCMSB +
28 UCMST + UCMODE_3 + UCSYNC);
31 HWREG8(baseAddress + OFS_UCBxCTL1) &= ~(UCSSEL_3);
34 HWREG8(baseAddress + OFS_UCBxCTL1) |=
param->selectClockSource;
36 HWREG16(baseAddress + OFS_UCBxBRW) =
37 (uint16_t)(
param->clockSourceFrequency /
param->desiredSpiClock);
46 HWREG8(baseAddress + OFS_UCBxCTL0) |= (
49 param->clockPolarity +
58 void USCI_B_SPI_changeMasterClock(uint16_t baseAddress,
59 USCI_B_SPI_changeMasterClockParam *
param)
62 HWREG8(baseAddress + OFS_UCBxCTL1) |= UCSWRST;
64 HWREG8(baseAddress + OFS_UCBxBRW) =
65 (uint16_t)(
param->clockSourceFrequency /
param->desiredSpiClock);
68 HWREG8(baseAddress + OFS_UCBxCTL1) &= ~(UCSWRST);
70 bool USCI_B_SPI_initSlave (uint16_t baseAddress,
77 HWREG8(baseAddress + OFS_UCBxCTL1) |= UCSWRST;
80 HWREG8(baseAddress + OFS_UCBxCTL0) &= ~(UCMSB +
89 HWREG8(baseAddress + OFS_UCBxCTL0) |= ( clockPhase +
99 void USCI_B_SPI_changeClockPhasePolarity (uint16_t baseAddress,
101 uint8_t clockPolarity
106 HWREG8(baseAddress + OFS_UCBxCTL1) |= UCSWRST;
108 HWREG8(baseAddress + OFS_UCBxCTL0) &= ~(UCCKPH + UCCKPL);
110 HWREG8(baseAddress + OFS_UCBxCTL0) |= (
116 HWREG8(baseAddress + OFS_UCBxCTL1) &= ~(UCSWRST);
119 void USCI_B_SPI_transmitData ( uint16_t baseAddress,
126 uint8_t USCI_B_SPI_receiveData (uint16_t baseAddress)
128 return (
HWREG8(baseAddress + OFS_UCBxRXBUF)) ;
131 void USCI_B_SPI_enableInterrupt (uint16_t baseAddress,
135 HWREG8(baseAddress + OFS_UCBxIE) |= mask;
138 void USCI_B_SPI_disableInterrupt (uint16_t baseAddress,
142 HWREG8(baseAddress + OFS_UCBxIE) &= ~mask;
145 uint8_t USCI_B_SPI_getInterruptStatus (uint16_t baseAddress,
149 return (
HWREG8(baseAddress + OFS_UCBxIFG) & mask );
152 void USCI_B_SPI_clearInterrupt (uint16_t baseAddress,
156 HWREG8(baseAddress + OFS_UCBxIFG) &= ~mask;
159 void USCI_B_SPI_enable (uint16_t baseAddress)
162 HWREG8(baseAddress + OFS_UCBxCTL1) &= ~(UCSWRST);
165 void USCI_B_SPI_disable (uint16_t baseAddress)
168 HWREG8(baseAddress + OFS_UCBxCTL1) |= UCSWRST;
171 uint32_t USCI_B_SPI_getReceiveBufferAddressForDMA (uint16_t baseAddress)
173 return ( baseAddress + OFS_UCBxRXBUF );
176 uint32_t USCI_B_SPI_getTransmitBufferAddressForDMA (uint16_t baseAddress)
178 return ( baseAddress + OFS_UCBxTXBUF );
181 uint8_t USCI_B_SPI_isBusy (uint16_t baseAddress)
184 return (
HWREG8(baseAddress + OFS_UCBxSTAT) & UCBUSY);
MPU_initThreeSegmentsParam param